<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
	<head>
		<title></title>

		<link href="<s:url value="../css/work.css"/>" rel="stylesheet"
			type="text/css" />

<link rel="StyleSheet" href="../css/dtree.css" type="text/css" />
		<script type="text/javascript" src="../js/dtree.js"></script>
		<script language="javascript" type="text/javascript">
		
	function back()
	 {
		history.go(-1);	 
	}
	
	function Check()
     	{
       		if( ! checkRequiredInformation())
       		{
         		return false;
       		}
       		return true;
        }
        
        function checkRequiredInformation()
    	{
			if(trim(document.form1.elements["doc"].value)== "")
				{
					alert("请选择文件");
					document.form1.elements["doc"].focus();
					return false;
				}
				
			var doc = "doc";
			var pdf = "pdf";
			if(trim(document.form1.elements["doc"].value)!="" )
					   {
						   	var fileType = false;	
					       	 var  path=trim(document.form1.elements["doc"].value);
					         var  path_array=path.split(".");
					         var  ExtName=path_array[path_array.length-1];
					         if( ExtName.toLowerCase()==doc||ExtName.toLowerCase()==pdf)
					         {
					            fileType=true;
					         }    
					         
					         if( !fileType )
					         {
					            alert("Uploaded type is invalid!");
					            document.form1.elements["doc"].focus();
					            return false;
					         }
					   }
			return true;
    	}
    	
    	function  trim(str)  //去掉字符串的前后空格
		{
		   for(var i =0;i<str.length && str.charAt(i)==" ";  i++  )  ;
		   for(var j =str.length; j>0 && str.charAt(j-1)==" "; j--)  ;
		   if(i>j)  return  "";
		   return  str.substring(i,j);
		}
</script>



	</head>


	<body onload="javascript:form1.title.focus();">


          


		<s:form namespace="/project" action="doAddReportForProjectAction"
			theme="simple" method="post" name="form1" id="form1"
			enctype="multipart/form-data">
			
			
   <h1>添加项目报告</h1>
            
			<s:hidden name="project.pid"></s:hidden>
			<table class="tableForm">


				<tr >
					<td style="height:50px" >
						<label>
							  文件路径
						</label>
					</td>
					<td>
						<s:file name="doc" label="file" id="doc" size="75"></s:file>
						<font color="#ff0000">
								<s:fielderror>
									<s:param>doc</s:param>
								</s:fielderror>							
							 </font>
							 
						<br/>
						
						
						
						
					</td>
				</tr>


				<tr>
					<td colspan="2" class="submitRow">
						<s:submit onclick="return Check()"></s:submit>
						&nbsp;&nbsp;
						<s:reset></s:reset>
						&nbsp;&nbsp;
											
						 <input type="button" value="Return" onclick="return back()" style="width:100px" />
					</td>
				</tr>

			</table>

		</s:form>


	</body>
</html>
